AppRoleForm = Ext
		.extend(
				Ext.Window,
				{
					formPanel : null,
					constructor : function(a) {
						Ext.applyIf(this, a);
						this.initUIComponents();
						AppRoleForm.superclass.constructor.call(this, {
							layout : "fit",
							items : this.formPanel,
							modal : true,
							id : "AppRoleFormWin",
							title : "角色详细信息",
							iconCls : "menu-role",
							width : 370,
							height : 220,
							buttonAlign : "center",
							buttons : this.buttons
						});
					},
					initUIComponents : function() {
						this.formPanel = new Ext.FormPanel({
							url : __ctxPath + "/system/saveAppRole.do?isCopy="
									+ this.isCopy,
							layout : "form",
							id : "AppRoleForm",
							border : false,
							bodyStyle : "padding:5px;",
							defaults : {
								anchor : "96%,96%"
							},
							formId : "AppRoleFormId",
							defaultType : "textfield",
							items : [ {
								name : "appRole.roleId",
								xtype : "hidden",
								value : this.roleId == null ? "" : this.roleId
							}, {
								fieldLabel : "角色名称",
								name : "appRole.roleName"
							}, {
								fieldLabel : "角色描述",
								xtype : "textarea",
								name : "appRole.roleDesc"
							}, {
								fieldLabel : "状态",
								hiddenName : "appRole.status",
								xtype : "combo",
								mode : "local",
								editable : true,
								triggerAction : "all",
								store : [ [ "0", "禁用" ], [ "1", "可用" ] ],
								value : 1
							} ]
						});
						if (this.roleId != null && this.roleId != "undefined") {
							this.formPanel.loadData({
								url : __ctxPath
										+ "/system/getAppRole.do?appRole.roleId="
										+ this.roleId,
								preName : "appRole",
								root : "result"
							});
						}
						this.buttons = [ {
							text : "保存",
							iconCls : "btn-save",
							scope : this,
							handler : this.save.createCallback(this)
						}, {
							text : "取消",
							iconCls : "btn-cancel",
							scope : this,
							handler : function() {
								this.close();
							}
						} ];
					},
					save : function() {
						var b = Ext.getCmp("AppRoleForm");
						if (this.isCopy == 1) {
							var a = Ext.getCmp("roleName").getValue();
							Ext.Ajax
									.request({
										url : __ctxPath
												+ "/system/checkAppRole.do",
										params : {
											roleName : a
										},
										method : "post",
										success : function(d) {
											var c = Ext.util.JSON
													.decode(d.responseText);
											if (c.success) {
												if (b.getForm().isValid()) {
													b
															.getForm()
															.submit(
																	{
																		method : "post",
																		waitMsg : "正在提交数据...",
																		success : function(
																				e,
																				f) {
																			Ext.ux.Toast
																					.msg(
																							"操作提示",
																							"信息保存成功！");
																			Ext
																					.getCmp(
																							"AppRoleGrid")
																					.getStore()
																					.reload();
																			Ext
																					.getCmp(
																							"AppRoleFormWin")
																					.close();
																		},
																		failure : function(
																				e,
																				f) {
																			Ext.MessageBox
																					.show({
																						title : "操作提示",
																						msg : "信息保存出错，请联系管理员！",
																						buttons : Ext.MessageBox.OK,
																						icon : "ext-mb-error"
																					});
																			Ext
																					.getCmp(
																							"AppRoleFormWin")
																					.close();
																		}
																	});
												}
											} else {
												Ext.ux.Toast.msg("提示信息",
														"该角色名字已经存在，请更改！");
											}
										},
										failure : function() {
										}
									});
						} else {
							if (b.getForm().isValid()) {
								b
										.getForm()
										.submit(
												{
													method : "post",
													waitMsg : "正在提交数据...",
													success : function(c, d) {
														Ext.ux.Toast.msg(
																"操作提示",
																"信息保存成功！");
														Ext.getCmp(
																"AppRoleGrid")
																.getStore()
																.reload();
														Ext
																.getCmp(
																		"AppRoleFormWin")
																.close();
													},
													failure : function(c, d) {
														Ext.MessageBox
																.show({
																	title : "操作提示",
																	msg : "信息保存出错，请联系管理员！",
																	buttons : Ext.MessageBox.OK,
																	icon : "ext-mb-error"
																});
														Ext
																.getCmp(
																		"AppRoleFormWin")
																.close();
													}
												});
							}
						}
					}
				});